package paperToChaKanChengJi

import android.app.Application
import androidx.databinding.ObservableField
import androidx.lifecycle.MutableLiveData
import com.lancoo.znbkxx.teacher.Ext
import com.lancoo.znbkxx.teacher.base.BaseViewModel
import com.lancoo.znbkxx.teacher.model.repository.CheckScoreRepository
import paperToChaKanChengJi.data.PaperAnalysisInfo

/**
 * Created by Dadong on 2020/3/19
 * Describe:
 */
class CheckScoreViewModel(application: Application) : BaseViewModel(application) {
    val title = ObservableField<String>()
    val submitNum = ObservableField<String>()
    val unSubmitNum = ObservableField<String>()
    val finishNum = ObservableField<String>()
    val avgNum = ObservableField<String>()
    val topNum = ObservableField<String>()
    val goodNum = ObservableField<String>()
    val passNum = ObservableField<String>()


    val paperAnalysisInfo = MutableLiveData<PaperAnalysisInfo>()
    val mErrorMsg = MutableLiveData<String>()

    private val repository by lazy { CheckScoreRepository() }

    fun getPaperAnalysis(
            userId: String,
            token: String,
            setID:String,
            paperID: String,
            schoolID: String,
            courseClassID: String
    ) {
        launch {
            val result = repository.getPaperAnalysis(
                    userId,
                    token,
                    setID,
                    paperID,
                    schoolID,
                    courseClassID)
            Ext.executeResponse(
                    result,
                    { paperAnalysisInfo.value = result.Data },
                    { mErrorMsg.value = result.Message })
        }
    }

    interface DataCallback {
        fun onSuccess(path: String)
        fun onError(msg: String)
    }

}


